import { Controller } from "../../mvc/core/Controller";
import { SIssmHintIcon } from "../view/issm/SIssmHintIcon";
import { NetDispatcher } from "../../mvc/core/NetDispatcher";
import { ServerCommand } from "../mvc/ServerCommand";
import { Dispatcher } from "../../mvc/core/Dispatcher";
import { EventName } from "../mvc/EventName";
import { DataEvent } from "../events/DataEvent";
import { MsgManager } from "../manager/MsgManager";
import { SIssmMsg } from "../../../Message/Game/SIssmMsg";
import { ParamsConst } from "../../common/global/ParamsConst";
import { Language } from "../../../extend/language/Language";
import { Alert } from "../../../com/mui/controls/Alert";
import { IssmNoticItem } from "../view/msgbroad/IssmNoticItem";
import { IssmAlertWin } from "../view/common/alertwins/IssmAlertWin";
import { Global } from "../../../com/gengine/global/Global";
type int = number;
//class IssmController
    
    export  class IssmController extends Controller
    {
       

        /* internal  */get issmHintIcon(): SIssmHintIcon
        {
            if (!this._issmHintIcon) 
            {
                this._issmHintIcon = new SIssmHintIcon();
            }
            return this._issmHintIcon;
        }

        protected /* override */ initServer(): void
        {
            NetDispatcher.addCmdListener(ServerCommand.IssmUpdata, this.showIssmPanel);
            Dispatcher.addEventListener(EventName.IssmVerified, this.issmVerified);
            return;
        }

        /* internal  */issmVerified(arg1: DataEvent): void
        {
            this.issmHintIcon.hideHint();
            MsgManager._msgIssmImpl.removeAllItem();
            return;
        }

        /* internal  */showIssmPanel(arg1: Object): void
        {
            var loc2=null;
            var loc3=null;
            var loc1=arg1 as SIssmMsg;
            if (loc1.issm == 1) 
            {
                this.issmHintIcon.hideHint();
                this.issmHintIcon.flashAlert(false);
                MsgManager._msgIssmImpl.removeAllItem();
            }
            else 
            {
                this.issmHintIcon.showHint();
                var loc4=loc1.onlineHour;
                switch (loc4) 
                {
                    case 0:
                    {
                        if (ParamsConst.instance.issmType == 0) 
                        {
                            return;
                        }
                        loc2 = Language.getString(51079);
                        Alert.mode = Alert.Mode_NoneNotModal;
                        Alert.show(loc2, null, Alert.OK, null, this.closeHandler);
                        break;
                    }
                    case 1:
                    {
                        loc2 = Language.getString(51080);
                        this.alert(loc2, Alert.OK | Alert.CANCEL);
                        this.issmHintIcon.showHint();
                        (loc3 = new IssmNoticItem()).updateData(loc2);
                        MsgManager._msgIssmImpl.addItem(loc3);
                        this.issmHintIcon.flashAlert(true);
                        break;
                    }
                    case 2:
                    {
                        loc2 = Language.getString(51081);
                        this.alert(loc2, Alert.OK | Alert.CANCEL);
                        this.issmHintIcon.showHint();
                        (loc3 = new IssmNoticItem()).updateData(loc2);
                        MsgManager._msgIssmImpl.addItem(loc3);
                        this.issmHintIcon.flashAlert(true);
                        break;
                    }
                    case 3:
                    {
                        break;
                    }
                    case 5:
                    {
                        loc2 = Language.getString(51082);
                        Alert.alertWinRenderer = IssmAlertWin;
                        this.alert(loc2, Alert.OK, Alert.Mode_NoneNotModal);
                        (loc3 = new IssmNoticItem()).updateData(loc2);
                        MsgManager._msgIssmImpl.addItem(loc3);
                        this.issmHintIcon.showHint();
                        this.issmHintIcon.flashAlert(true);
                        break;
                    }
                    case 7:
                    {
                        loc2 = Language.getString(51083);
                        this.alert(loc2, Alert.OK, Alert.Mode_NoneNotModal);
                        (loc3 = new IssmNoticItem()).updateData(loc2);
                        MsgManager._msgIssmImpl.addItem(loc3);
                        this.issmHintIcon.showHint();
                        this.issmHintIcon.flashAlert(true);
                    }
                    case 9:
                    {
                        break;
                    }
                    default:
                    {
                        break;
                    }
                }
            }
            return;
        }

        /* internal  */alert(arg1: string, arg2: uint=4, arg3: string="simple"): void
        {
            Alert.mode = arg3;
            Alert.show(arg1, null, arg2, Global.stage as Object /* flash.display.Sprite */, this.closeHandler);
            return;
        }

        /* internal  */closeHandler(arg1: int): void
        {
            if (arg1 == Alert.OK) 
            {
                SIssmHintIcon.gotoIssm();
            }
            return;
        }

        private /* var */firstWarning: Boolean=false;

        private /* var */messageStr: string;

        private /* var */_issmHintIcon: SIssmHintIcon;
    }
